package com.diudiu.diudiu.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.diudiu.diudiu.common.R;
import com.diudiu.diudiu.entity.UserFaceAi;
import com.diudiu.diudiu.mapper.UserFaceAiMapper;
import com.diudiu.diudiu.service.FaceAiService;
import com.diudiu.diudiu.service.UserService;
import lombok.Data;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/faceai")
@CrossOrigin
public class FaceAiController {

    @Autowired
    FaceAiService faceAiService;

    @Autowired
    UserFaceAiMapper userFaceAiMapper;


    @PostMapping("/addUser")
    public R addUser(String image,  String userId ){
        faceAiService.addUser(image, userId);
        return R.ok();
    }

    @PostMapping("/faceDelete")
    public R faceDelete(String userId){
        String faceToken = "123456";
        faceAiService.faceDelete(userId,faceToken);
        return R.ok();
    }

    @PostMapping("/list")
    public R faceList(){
        QueryWrapper<UserFaceAi> queryWrapper = new QueryWrapper<>();
        return R.ok(userFaceAiMapper.selectList(queryWrapper));
    }

    @PostMapping("/search")
    public R search(@RequestBody Face face){
        return R.ok(faceAiService.search(face.getImage(),face.getUserId(),face.getState()));
    }



}
class Face{
    Integer userId;
    String image;
    int state;

    public Face(Integer userId,String image,int state) {
        this.userId = userId;
        this.image = image;

        this.state = state;

    }

    Integer getUserId() {
        return userId;
    }

    int getState() {
        return state;
    }

    void setState(int state) {
        this.state = state;
    }


    void setUserId(Integer userId) {
        this.userId = userId;
    }

    String getImage() {
        return image;
    }

    void setImage(String image) {
        this.image = image;
    }
}